<template>
  <div class="login-container">
    <!-- 登录容器 - 完全按照图片重写 -->
    <div class="login-wrapper">
      <!-- 标签页容器 - 图片中的特殊形状设计 -->
      <!-- <div class="tab-container-login">
        <div class="login-tab">
          <img
            src="@/assets/home/logo_active.png"
            alt=""
            style="max-width: 20px; margin-right: 10px"
          />
          登录
        </div>
        <div class="register-tab">注册</div>
      </div> -->
      <div class="tab-container-register">
        <div class="login-tab">登录</div>
        <div class="register-tab">
          <img
            src="@/assets/home/logo_active.png"
            alt=""
            style="max-width: 20px; margin-right: 10px"
          />注册
        </div>
      </div>

      <!-- 登录内容区域 -->
      <div class="login-content">
        <!-- 微信登录标题 -->
        <div style="width: 100%; display: flex">
          <div class="login-title content">微信登录</div>
        </div>

        <!-- 二维码区域 -->
        <div class="qrcode-container">
          <div class="qrcode-wrapper">
            <img
              src="@/assets/qrcode_service.png"
              alt="微信登录二维码"
              class="qrcode"
            />
          </div>

          <!-- 扫码提示 -->
          <p class="scan-tip">使用微信扫一扫，一键登录</p>
        </div>

        <!-- 异常处理链接 -->
        <div class="help-section f13">
          登录异常？可咨询<a href="#" class="help-link">客服</a>
        </div>
      </div>
    </div>

    <!-- 版权信息 -->
    <div class="copyright">
      <p>北京优易捷科技有限责任公司 版权所有 © 2008-2025 Inc.</p>
    </div>
  </div>
</template>

<script>
import { Message } from "element-ui";

export default {
  name: "Login",
  data() {
    return {
      isLoginTab: true,
      countdown: 60,
      timer: null,
    };
  },
  mounted() {
    // 启动二维码刷新倒计时
    this.startRefreshTimer();
  },
  beforeDestroy() {
    // 清除定时器
    if (this.timer) {
      clearInterval(this.timer);
    }
  },
  methods: {
    // 切换到登录标签
    switchToLogin() {
      this.isLoginTab = true;
    },

    // 切换到注册标签
    switchToRegister() {
      this.isLoginTab = false;
      Message.info("注册功能暂未开放");
    },

    // 刷新二维码
    refreshQrcode() {
      // 这里可以添加刷新二维码的逻辑
      Message.success("二维码已刷新");
      this.resetRefreshTimer();
    },

    // 启动刷新定时器
    startRefreshTimer() {
      this.countdown = 60;
      this.timer = setInterval(() => {
        this.countdown--;
        if (this.countdown <= 0) {
          this.refreshQrcode();
        }
      }, 1000);
    },

    // 重置刷新定时器
    resetRefreshTimer() {
      if (this.timer) {
        clearInterval(this.timer);
      }
      this.startRefreshTimer();
    },

    // 咨询客服
    contactService() {
      Message.info("正在连接客服...");
    },
  },
};
</script>

<style scoped lang="scss">
// 全局样式重置
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.login-container {
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;

  // 装饰背景元素 - 模拟图片中的浅灰色纹理
  &::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: radial-gradient(
        circle at 20% 30%,
        rgba(255, 255, 255, 0.7) 0%,
        transparent 25%
      ),
      radial-gradient(
        circle at 80% 20%,
        rgba(255, 255, 255, 0.5) 0%,
        transparent 30%
      ),
      radial-gradient(
        circle at 50% 80%,
        rgba(255, 255, 255, 0.6) 0%,
        transparent 35%
      );
    pointer-events: none;
  }
}

.logo-area {
  display: flex;
  align-items: center;
  margin-bottom: 30px;
  position: relative;
  z-index: 1;
}

.logo {
  width: 40px;
  height: 40px;
  margin-right: 10px;
}

.logo-text {
  font-size: 24px;
  font-weight: bold;
  color: #333;
}

// 主要登录容器 - 完全按照图片重写样式
.login-wrapper {
  width: 430px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

// 标签页容器 - 特殊形状设计
.tab-container-login {
  display: flex;
  height: 60px;
  position: relative;
  // 登录标签样式
  .login-tab {
    flex: 6;
    display: flex;
    align-items: center;
    font-size: 16px;
    padding-left: 30px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    background: #ffffff;
    position: relative;
    z-index: 2;
    border-radius: 12px 0 0 0;

    &.active {
      color: #333;
    }

    .tab-icon {
      margin-right: 6px;
      font-size: 18px;
    }
  }

  // 注册标签样式 - 图片中的蓝色设计
  .register-tab {
    flex: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    background: #409eff;
    position: relative;
    border-radius: 0 12px 0 0;
  }
}

.tab-container-register {
  display: flex;
  height: 60px;
  position: relative;
  // 登录标签样式
  .login-tab {
    flex: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    background: #409eff;
    position: relative;
    border-bottom-right-radius: 30px;
    margin-right: -10px;
  }

  // 注册标签样式 - 图片中的蓝色设计
  .register-tab {
    flex: 6;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 16px;
    padding-right: 30px;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    background: #ffffff;
    position: relative;
    z-index: 2;
    border-top-left-radius: 10px;

    &.active {
      color: #333;
    }

    .tab-icon {
      margin-right: 6px;
      font-size: 18px;
    }
  }
}

// 登录内容区域
.login-content {
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

// 微信登录标题样式
.login-title {
  font-size: 16px;
  font-weight: 500;
  color: #348cf8;
  margin-bottom: 30px;
  padding-bottom: 15px;
  text-align: center;
  position: relative;

  // 使用 content 方式添加下划线
  &::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 73px;
    height: 4px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    background-color: #348cf8;
  }
}

// 二维码容器
.qrcode-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 30px;
}

// 二维码包装器
.qrcode-wrapper {
  // width: 200px;
  // background: #ffffff;
  // display: flex;
  // align-items: center;
  // justify-content: center;
  margin-bottom: 10px;
}

// 二维码图片
.qrcode {
  width: 160px;
  height: 160px;
}

// 扫码提示文字
.scan-tip {
  font-size: 14px;
  color: #666;
  text-align: center;
  line-height: 1.6;
}

// 帮助链接区域
.help-section {
  text-align: center;
}

// 帮助链接样式
.help-link {
  font-size: 13px;
  color: #409eff;
  text-decoration: none;
  transition: color 0.3s ease;
}

.help-link:hover {
  color: #66b1ff;
  text-decoration: underline;
}

// 版权信息样式
.copyright {
  position: absolute;
  bottom: 20px;
  text-align: center;
  font-size: 12px;
  color: #999;
  z-index: 1;
}

// 响应式设计
@media (max-width: 480px) {
  .login-wrapper {
    width: 100%;
    max-width: 360px;
  }

  .login-content {
    padding: 30px 20px;
  }

  .qrcode-wrapper {
    width: 180px;
    height: 180px;
  }

  .qrcode {
    width: 140px;
    height: 140px;
  }

  .copyright {
    position: relative;
    margin-top: 30px;
    bottom: auto;
  }
}
</style>
